package com.lagou.controller;

import org.springframework.web.WebApplicationInitializer;

import javax.servlet.ServletContainerInitializer;
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import java.util.Set;

/**
 * @Authther: mrwu
 * @date:2021/3/28-03
 * @Description:com.lagou.controller
 */
public class MySpringServletContainerInitializer implements ServletContainerInitializer {
    @Override
    public void onStartup(Set<Class<?>> c, ServletContext ctx) throws ServletException {
        c.forEach(aClass -> {
            WebApplicationInitializer o = null;
            try {
                o = (WebApplicationInitializer)aClass.newInstance();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
            try {
                o.onStartup(ctx);
            } catch (ServletException e) {
                e.printStackTrace();
            }
        });
    }
}
